/////////////////////////////////////////////////////////////////////////
//
// Amuse Engine SDK - geometry/containment
// Copyright( c) 2015.  All Rights Reserved
//
// File:		AEStaticSubmeshInstance.cpp
// Author:		Gianluca Belardelli
// Date:		19/06/2015
//
/////////////////////////////////////////////////////////////////////////
#include <AEEngine.h>

AEStaticSubmeshInstance::AEStaticSubmeshInstance( void ) : AEStaticGeometryInstance()
{
}

AEStaticSubmeshInstance::~AEStaticSubmeshInstance( void )
{
}

void AEStaticSubmeshInstance::ComputeSortingKey( void )
{
}

AEINT32 AEStaticSubmeshInstance::GetNumPrimitives( void )
{
	return 0;
}

AEINT32 AEStaticSubmeshInstance::GetSupportedStreamMask( void )
{
	return 0;
}

void AEStaticSubmeshInstance::DebugRenderCollisionMesh( AEColor crMeshColor, AEColor crNormalColor, AEFLOAT32 fNormalLength )
{
}
/*#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
using namespace glm;*/
void AEStaticSubmeshInstance::Render( void )
{
	AEINT32 nStart, nVerticesOrIndices;
	if( m_lpMeshInstance->GetMesh()->GetMeshBufferStreamMask() & AEVERTEXSTREAM_INDEXBUFFER )
		m_lpSubmesh->GetRenderRange( nStart, nVerticesOrIndices );
	else
		m_lpSubmesh->GetRenderVertexRange( nStart, nVerticesOrIndices );

	AEMeshBuffer *lpMeshBuffer = m_lpSubmesh->GetMesh()->GetMeshBuffer();
	/*
	AEMatrix4f matWorld = m_lpMeshInstance->GetTransform();

	AEMatrix4f matProj;
	matProj = AEngine::GetMainRenderContext()->GetProjectionMatrix();

	AEMatrix4f matLookAt;
	matLookAt.SetIdentity();
	matLookAt.SetLookAtMatrix( AEVector4f( 3.0, 3.0f, 4.0f ), AEVector4f( 0.0, 0.0, 0.0 ), AEVector4f( 0.0, 1.0, 0.0 ) );

	AEMatrix4f matMVP;
	matMVP.SetMul( matLookAt,  matProj );
	matWorld.Mul( matMVP );

	GLint programID;
	glGetIntegerv (GL_CURRENT_PROGRAM,&programID );

	GLfloat fMatrix[16];

	matWorld.Get( fMatrix, AEMatrixLayout::AEML_RowMajor );
	GLuint MatrixID = glGetUniformLocation( programID, "MVP" );

	glUniformMatrix4fv( MatrixID, 1, GL_FALSE, (GLfloat *)&fMatrix );*/
	//glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
	//lpMeshBuffer->RenderBuffer( matWorld, nStart, nVerticesOrIndices );
	lpMeshBuffer->RenderBuffer( nStart, nVerticesOrIndices );
}
// AEINT32 AEStaticSubmeshInstance::TraceTest( const AEVector3f &vcStartOfLine, const AEVector3f &vcEndOfLine, AEINT32 nStoreResultCount=0, VisTraceLineInfo_t *pFirstTraceInfo=AENULL);

